#ifndef __UTIL_TIMER_H__
#define __UTIL_TIMER_H__

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <string.h>

typedef void (*handler_t)(void *arg);

typedef struct
{
    //定时器回调函数
    handler_t func;
    //定时器回调函数参数
    void *arg;
    // 定时器对象
    timer_t timer;
    // 定时器到期事件设置
    struct sigevent evp;
    // 定时器间隔设置
    struct itimerspec it;
    // 定时器总超时次数
    int cnt_max;
    // 定时器已超时次数
    int cnt_cur;
} timer_conf_t;

int timer_stop(timer_conf_t *conf);
int timer_destory(timer_conf_t *conf);
int timer_start(timer_conf_t *conf, int interval, int repeat, handler_t func,void *arg);
int timer_config(timer_conf_t *conf,int timeout);

#endif /* __UTIL_TIMER_H__ */
